package antani.client.widgets;

import antani.client.GWTClient;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;

public class AlbumItem extends Widget {

	interface MyUiBinder extends UiBinder<DivElement, AlbumItem> {
	}

	private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

	@UiField
	DivElement albumName;
	@UiField
	SpanElement artistName;

	String id;

	public AlbumItem(String id, String album, String artist) {
		setElement(uiBinder.createAndBindUi(this));
		sinkEvents(Event.ONCLICK);
//		sinkEvents(com.google.gwt.user.client.Event.ONMOUSEOVER);
//		sinkEvents(Event.ONMOUSEOUT);

		albumName.setInnerText(album);
		artistName.setInnerText(artist);
		this.id = id;
	}

	// @Override
	public void onBrowserEvent(com.google.gwt.user.client.Event event) {
		// System.out.println(DOM.eventGetType(event));
		switch (DOM.eventGetType(event)) {
//		case Event.ONMOUSEOVER:
//			setStyleName("aover");
//			break;
//		case Event.ONMOUSEOUT:
//			setStyleName("aout");
//			break;
		case Event.ONCLICK:
			GWTClient.albumsPage.showAlbumPopup(id);
//			PlayerPage.playAlbum(id);
		}
	}

}
